Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

convert-source-map

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

convert-source-map

Converts a source-map from/to different formats and allows adding/changing properties.

  • 1.9.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
62M
decreased by-7.05%
Maintainers
1
Weekly downloads
 
Created

What is convert-source-map?

The convert-source-map npm package is used for dealing with inline and external source maps. It provides functionalities to convert source maps between different formats, such as from a JSON object to a base64-encoded string or from a base64-encoded string to a JSON object. It can also add and remove source map comments from files or code strings.

What are convert-source-map's main functionalities?

Convert source map from JSON to base64

This feature allows you to convert a source map from a JSON object to a base64-encoded string, which can be appended to a file as an inline source map.

const convert = require('convert-source-map');
const sourceMap = { version: 3, file: 'out.js', sources: ['foo.js', 'bar.js'], names: [], mappings: 'AAgBC' };
const base64Map = convert.fromObject(sourceMap).toBase64();

Convert source map from base64 to JSON

This feature allows you to convert a base64-encoded source map string back into a JSON object for further manipulation or analysis.

const convert = require('convert-source-map');
const base64Map = 'eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3V0LmpzIiwic291cmNlcyI6WyJmb28uanMiLCJiYXIuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBZ0JDIn0=';
const sourceMap = convert.fromBase64(base64Map).toObject();

Add source map comment to code

This feature enables you to append a source map comment to a string of code, which can be useful when generating code dynamically.

const convert = require('convert-source-map');
const code = 'function foo() {}';
const sourceMap = convert.fromObject({ version: 3, sources: ['foo.js'], names: [], mappings: 'AAAA' });
const codeWithSourceMap = code + '\n' + sourceMap.toComment();

Remove source map comment from code

This feature allows you to remove source map comments from a string of code, which can be useful when you need to process the code further without the source map.

const convert = require('convert-source-map');
const codeWithSourceMap = 'function foo() {}\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImZvby5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9';
const codeWithoutSourceMap = convert.removeComments(codeWithSourceMap);

Other packages similar to convert-source-map

Keywords

FAQs

Package last updated on 10 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc